package com.longge;

/**
 * @创建人 xinglongge
 * @创建时间 2021/11/19
 * @描述
 */
public class TwoSum {
    public int[] twoSum(int[] numbers, int target) {
        int left = 0, right = numbers.length - 1;
        while (left <= right) {
            int sum = numbers[left] + numbers[right];
            if (sum > target) right--;
            else if (sum < target) left++;
            else return new int[]{left + 1, right + 1};
        }
        return new int[]{};
    }
}
